package msgs

import (
	"context"
	"zuhao-seucre/internal/dao"
	"zuhao-seucre/internal/model/do"
	"zuhao-seucre/internal/model/vo"
	"zuhao-seucre/internal/service"

	"zuhao-seucre/api/msgs/v1"
)

func (c *ControllerV1) GetMsgPageList(ctx context.Context, req *v1.GetMsgPageListReq) (res *v1.GetMsgPageListRes, err error) {
	res = new(v1.GetMsgPageListRes)
	var (
		array []*vo.Msg
		count int
	)
	err = dao.TSysMsg.Ctx(ctx).Where(do.TSysMsg{
		RecipientId: service.ContextX().GetUser(ctx).UserId,
	}).Page(req.PageNum, req.PageSize).ScanAndCount(&array, &count, false)

	res.List = array
	res.TotalCount = count
	return
}
